package network;

import java.net.InetAddress;
import java.net.UnknownHostException;

import hypeerweb.Contents;
import hypeerweb.Node;
import hypeerweb.NodeState;
import hypeerweb.SimplifiedNodeDomain;
import hypeerweb.Visitor;
import hypeerweb.WebId;

public class NodeProxy extends Node {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1421916584859333431L;
	/**
	 * 
	 */
	private GlobalObjectId globalObjectId;

	public NodeProxy(GlobalObjectId globalObjectId) {
		super(0);
		this.globalObjectId = globalObjectId;
	}

	public boolean isProxy() {
		return true;
	}

	public java.lang.String toString() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "toString", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (java.lang.String) result;
	}

	public int compareTo(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "compareTo", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Integer) result;
	}

	public int compareTo(NodeProxy p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "java.lang.Object";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "compareTo", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Integer) result;
	}

	public NodeState getState() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getState", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (NodeState) result;
	}

	public void accept(Visitor p0, hypeerweb.Parameters p1) {
		String[] parameterTypeNames = new String[2];
		parameterTypeNames[0] = "interface hypeerweb.Visitor";
		parameterTypeNames[1] = "hypeerweb.Parameters";
		Object[] actualParameters = new Object[2];
		actualParameters[0] = p0;
		actualParameters[1] = p1;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "accept", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void setState(NodeState p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.NodeState";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "setState", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public WebId getWebId() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getWebId", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (WebId) result;
	}

	public Contents getContents() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getContents", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (hypeerweb.Contents) result;
	}

	public Node getFold() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getFold", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Node) result;
	}

	public void setWebId(WebId p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.WebId";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "setWebId", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void addNeighbor(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "addNeighbor", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void addUpPointer(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "addUpPointer", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void setFold(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "setFold", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public Node getInverseSurrogateFold() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getInverseSurrogateFold",
				parameterTypeNames, actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (hypeerweb.Node) result;
	}

	public void setInverseSurrogateFold(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "setInverseSurrogateFold",
				parameterTypeNames, actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public java.util.TreeSet<Node> getAllNeighbors() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getAllNeighbors", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (java.util.TreeSet<Node>) result;
	}

	public java.util.TreeSet<Node> getLargerNeighbors() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getLargerNeighbors", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (java.util.TreeSet<Node>) result;
	}

	public Node getLargestNeighbor() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getLargestNeighbor", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Node) result;
	}

	public Node getSmallestNeighbor() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getSmallestNeighbor", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Node) result;
	}

	public java.util.TreeSet<Node> getDownPointers() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getDownPointers", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (java.util.TreeSet<Node>) result;
	}

	public java.util.TreeSet<Node> getUpPointers() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getUpPointers", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (java.util.TreeSet<Node>) result;
	}

	public Node getSurrogateFold() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getSurrogateFold", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Node) result;
	}

	public void removeNeighbor(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "removeNeighbor", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void addDownPointer(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "addDownPointer", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void removeDownPointer(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "removeDownPointer", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void removeUpPointer(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "removeUpPointer", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void setSurrogateFold(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "setSurrogateFold", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void addToHyPeerWeb(Node p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "hypeerweb.Node";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "addToHyPeerWeb", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public void removeFromHyPeerWeb() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "removeFromHyPeerWeb", parameterTypeNames,
				actualParameters, false);
		PeerCommunicator.getSingleton().sendSynchronous(globalObjectId,
				command);
	}

	public java.util.TreeSet<Node> getSmallerNeighborsWithoutChildren() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getSmallerNeighborsWithoutChildren",
				parameterTypeNames, actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (java.util.TreeSet<Node>) result;
	}

	public Node getSmallestNeighborWithoutChildren() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getSmallestNeighborWithoutChildren",
				parameterTypeNames, actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (hypeerweb.Node) result;
	}

	public java.util.TreeSet<Node> getSmallerNeighborsWithChildren() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "getSmallerNeighborsWithChildren",
				parameterTypeNames, actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (java.util.TreeSet<Node>) result;
	}

	public SimplifiedNodeDomain constructSimplifiedNodeDomain() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"hypeerweb.Node", "constructSimplifiedNodeDomain",
				parameterTypeNames, actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (hypeerweb.SimplifiedNodeDomain) result;
	}

	public boolean equals(java.lang.Object p0) {
		String[] parameterTypeNames = new String[1];
		parameterTypeNames[0] = "java.lang.Object";
		Object[] actualParameters = new Object[1];
		actualParameters[0] = p0;
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"java.lang.Object", "equals", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Boolean) result;
	}

	public int hashCode() {
		String[] parameterTypeNames = new String[0];
		Object[] actualParameters = new Object[0];
		Command command = new Command(globalObjectId.getLocalObjectId(),
				"java.lang.Object", "hashCode", parameterTypeNames,
				actualParameters, true);
		Object result = PeerCommunicator.getSingleton().sendSynchronous(
				globalObjectId, command);
		return (Integer) result;
	}
	
	public Object readResolve(){
		try {
			if(globalObjectId.onSameMachineAs(new GlobalObjectId(InetAddress.getLocalHost().getHostAddress(), PortNumber.getApplicationsPortNumber(), null))){
				return ObjectDB.getSingleton().getValue(globalObjectId.getLocalObjectId());
			}
			else{
				return this;
			}
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}
	
	public Object writeReplace(){
		return this;
	}
	
	
}